import { saveProfile, getProfiles } from '../../api/profile'

const actions = {

    save({commit}, params) {
        return new Promise((resolve, reject) => {
            saveProfile({name:params.name.trim()}).then(response => {
                resolve(response)
                commit("sss","sss")
                console.log(response)
            }).catch(error => {
                reject(error)
                console.log("error")
                console.log(error)
            })
        })
    },

    all(){
        return new Promise((resolve, reject) => {
            getProfiles().then(response => {
                const {data} = response
                resolve(data)
            }).catch(error => {
                reject(error)
            })
        })
    }

}

export default {
    namespaced: true,
    actions
}